﻿<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <script src="../../js/load.js"></script>
</head>

<body>
    <div id="container">
        <div id="formcontainer">
            <form class="layui-form layui-form-pane" id="editform" lay-filter="editform">
                <div class="layui-row">
                    <div class="layui-col-xs12">
                        <div class="layui-form-item">
                            <label class="layui-form-label required">名称</label>
                            <div class="layui-input-block">
                                <input type="text" name="ruleName" autocomplete="off" class="layui-input required">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-row">
                    <div class="layui-col-xs12">
                        <div class="layui-form-item" pane="">
                            <label class="layui-form-label required">协议</label>
                            <div class="layui-input-block">
                                <input type="radio" name="ruleProtocol" value="TCP" title="TCP" checked>
                                <input type="radio" name="ruleProtocol" value="UDP" title="UDP">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-row">
                    <div class="layui-col-xs12">
                        <div class="layui-form-item">
                            <label class="layui-form-label required">端口</label>
                            <div class="layui-input-block">
                                <input type="text" name="rulePort" autocomplete="off" class="layui-input required number">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-row">
                    <div class="layui-col-xs12">
                        <div class="layui-form-item" pane="">
                            <label class="layui-form-label required">策略</label>
                            <div class="layui-input-block">
                                <input type="radio" name="ruleAction" value="allow" title="允许" checked>
                            </div>
                        </div>
                    </div>
                </div>
            </form>
        </div>
        <div id="opcontainer">
            <button class="layui-btn" onclick="HandleSave()">确认</button>
            <button class="layui-btn layui-btn-primary" onclick="HandleClose()">关闭</button>
        </div>
    </div>
</body>
</html>
<script>
    $(function () {

    })

    function HandleSave() {
        var loading = layer.load('处理中...', {
            icon: 16,
            shade: 0.01
        })
        SubmitForm('editform', 'api/firewall/insert', BeforeSubmit, null, function (result, status) {
            layer.close(loading);
            if (result.code == 0) {
                OpenSuccess('添加成功', function (params) {
                    CloseDialog();
                })
            } else {
                OpenFail("添加失败");
            }
        })
    }

    function BeforeSubmit(data) {
        return true;
    }

    function HandleClose() {
        CloseDialog();
    }
</script>